#include <time.h>
#include <stdio.h>
#include <stdlib.h>
#include "getnum.h"
//macro definitions
#define SUCCESS 1
#define FAILURE 0
#define NORMAL 1
#define TIME 2
#define MULTIPLAYER 3
#define LOAD 3
#define QUIT 4
#define LOSER 5
#define CHECK 0
#define ERASE 1
#define CLEAN 2
#define BLANK 0
#define H_MIN 60
#define MIN_DIM 5
#define MIN_COLORS 2
#define MAX_COLORS 9
#define MAX_FNAME 50
#define MAX_CHIPTURN 15

#define ERASE_BUFFER while( getchar() != '\n' )

//struct declarations
typedef struct {
	int dimRow;
	int dimCol;
	int mode;
	int turn;
	int colors;
	int startChips;
	int turnChips;
	int makeLine;
	int **matrix;
	int **matrixBack;
	int points;
	int pointsBack;
	time_t iniTime;
	time_t time;
	time_t gameTime;
	time_t timeLeft;
} gameData;
//function definitions

//Function playing: Checks if player(s) are still playing
int playing( const gameData *player1, const gameData *player2 );
//newMatrix: returns a new matrix with dinRow and dimCol dimension
int ** newMatrix( int dimRow, int dimCol );
void freeMatrix( int dimRow, int **matrix );
//randomChips: puts random values between possible colors in empty slots 
void randomChips( gameData *player, int chips );
//ldMatrix: loads a saved matrix
int ldMatrix( gameData *player, FILE *file );
//svMatrix: saves an existing matrix
void svMatrix( gameData *player, FILE *file );
//cpyMatrix: copies matrix "from" into matrix "to"
void cpyMatrix( int **from, int **to, int fil, int col );

int checkSlots( const gameData *player );

void undo(gameData * player);
//moveChips: moves the chip from (x,y)start to (x,y)finish if possible
int moveChips( gameData *player, int xStart, int yStart, int xFinish, int yFinish );
//points: returns the amount of points you get if you make a line(s) in that (x,y) position with that color
int points(gameData * player, int x, int y, int color);
